

/* Bring in data from 1_Data_Cleaning.do */
clear all
use "data/outputs/clean_mm.dta", clear 


**----------------------------------**
**  Demographic Tables for Appendix **
**----------------------------------**

/* Generate categorical variables */
tabulate education, gen(education_level)
tabulate gender_pre, gen(gender_pre_level)
tabulate race, gen(race_level)
tabulate party3, gen(party3_level)
tabulate party7, gen(party7_level)
tabulate hh_income, gen(hh_income_level)

/* create an indicator for sample (non-missing across all three outcomes: diff, support and consisistency)*/
gen sample2 =0
replace sample2=1 if copartisan!=. & exp2_support!=. & exp2_consistent!=.
tab sample2

/* generate sum stats */
display _N
fsum gender_pre_level* year_of_birth race_level* education_level* /*
*/ hh_income_level* party7_level*, uselabel stats(n mean) format(%9.3f)

/* generate sum stats */
count if missing(exp1_scenario) == 0
fsum gender_pre_level* year_of_birth race_level* education_level* /*
*/ hh_income_level* party7_level* if missing(exp1_scenario) == 0, /*
*/ uselabel stats(n mean) format(%9.3f)

/* generate sum stats */
count if missing(exp2_scenario) == 0
fsum gender_pre_level* year_of_birth race_level* education_level* /*
*/ hh_income_level* party7_level* if missing(exp2_scenario) == 0, /*
*/ uselabel stats(n mean) format(%9.3f)

/* sum stats */
sutex gender_pre_level* year_of_birth race_level* education_level* /*
*/ hh_income_level* party7_level* if sample2==1, labels key("tab:sumstat") minmax digits(3) /*
*/ file("outputs/TableB1.tex") title("Descriptive Statistics Table (Full Sample in Experiment 1)") replace 

/* balance table */
iebaltab gender_pre_level* year_of_birth race_level* education_level* /*
*/ hh_income_level* party7_level* if sample2==1, rowvarlabels grpvar(exp1_scenario) savet("outputs/TableB2.tex") /*
*/ replace   format(%9.3f)   

/* End */   
